﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace Dune2013
{
    public class RecolectarBehavior : Behavior
    {
        Node pozoRecolecta;
        int velocidadExtraccion;// = 1;
        float velocidadGastoNafta;// = 1;
        public RecolectarBehavior(Node pozoARecolectar, int velocidadExtraccion, float velocidadGastoNafta) :
            base() {
                typeBehavior = TypeBehavior.Trabajo; 
                pozoRecolecta = pozoARecolectar;
                this.velocidadExtraccion = velocidadExtraccion;
                this.velocidadGastoNafta = velocidadGastoNafta;
        }
        public override void execute(int dTime, Actor act)
        {

            base.execute(dTime,act);
            act.scale += 0.01f;
            if(act is Recolector){
                Recolector recolector = (Recolector)act;
                recolector.carga += velocidadExtraccion;
                recolector.nafta -= velocidadGastoNafta;
            }
            pozoRecolecta.oil -= velocidadExtraccion;
            Recolector pepe = (Recolector)act;
            if (pepe.scale > pepe.maxSize || pozoRecolecta.oil <= 0)
            {
                pepe.changeBehavior(new IrAlmacenarBehavior());
                if (pozoRecolecta.oil <= 0)
                    NodeManager.getInstance().makeEmpty(pozoRecolecta);
            }
        }
        public override void enter(Actor act)
        {
            act.speed = 0;
            base.enter(act);
        }
        public override void exit(Actor act)
        {
            base.enter(act);
        }
        public override Behavior getIrABehavior()
        {
            return new IrCosecharBehavior();
        }
    }
}
